﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Elektronix
{
    public partial class captcha : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Bitmap objBMP = new System.Drawing.Bitmap(60,20);
            Graphics onjGraphics = System.Drawing.Graphics.FromImage(objBMP);
            onjGraphics.Clear(Color.Green);
            onjGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            Font objFont = new Font("Ariel", 8, FontStyle.Bold);
            string randstr = "";
            int[] myINTArray = new int[5];
            Random r = new Random();
            for (int i = 0; i < 5; i++)
            {
                myINTArray[i] = Convert.ToInt32(r.Next(0, 9));
                randstr += myINTArray[i].ToString();

            }

            Session["randstr"]=randstr;
            onjGraphics.DrawString(randstr, objFont, Brushes.White, 3, 3);
            Response.ContentType = "image/GIF";
            objBMP.Save(Response.OutputStream, ImageFormat.Gif);
            objFont.Dispose();
            onjGraphics.Dispose();
            objBMP.Dispose();

        }
    }
}